﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PlayingCards.Comm.Extensions
{
    public static class DateTimeExtension
    {
        public static string GetCurrentTimeAsNumber()
        {
            string uniqueNumber = Guid.NewGuid().ToString("N").Substring(0, 6);
            return uniqueNumber;
        }


        /// <summary>
        ///  随机生成4位数
        /// </summary>
        /// <returns></returns>
        public static string GenerateNumberString()
        {
            List<int> numbers = new List<int>();
            Random random = new Random();

            while (numbers.Count < 4)
            {
                int number = random.Next(0, 10);
                if (!numbers.Contains(number))
                {
                    numbers.Add(number);
                }
            }
            string result = "";
            for (int i = 0; i < numbers.Count; i++)
            {
                result += numbers[i].ToString();
            }

            return result;
        }
    }
}
